package top.canyue.eca_manager.tool;

import com.alibaba.fastjson2.JSON;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ParamTools {
    public static String paramsToJsonString(Object... param) {
        return JSON.toJSONString(param);
    }

    public static boolean containsSqlInjection(Object obj) {
        Pattern pattern = Pattern.compile(
                "select|update|and|or|delete|insert|truncate|char|into|substr|ascii|declare|exec|count|master|into|drop|execute|table|" +
                        "char|declare|sitename|xp_cmdshell|like|from|grant|use|group_concat|column_name|" +
                        "information_schema.columns|table_schema|union|where|order|by|" +
                        "'\\*|\\;|\\-|\\--|\\+|\\,|\\//|\\/|\\%|\\#");
        Matcher matcher = pattern.matcher(obj.toString().toLowerCase());
        return matcher.find();
    }
}
